;;;
;;;
;;;	Author:
;;;		Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;
;;;     http://paracadd.com
;;;	All rights reserved.
;;;
;;;Stamps the drawing and logs the saveas.
;;;
;;;Prior to DEFUN below (COMMAND ".undefine" "saveas") is required or this DEFUN will not
;;;redefuine QSAVE (COMMAND ".undefine" "saveas") can be executed from here or anywhere
;;;else as long as it is called before this DEFUN
;;;
(DEFUN c:saveas (/ fstr fndexst)
  (vl-load-com)
  (IF initandsdichk NIL (LOAD "initandsdichk" "\nFile INITANDSDICHK.LSP not loaded! "))
  (initandsdichk)
  (SETQ dwgpx (GETVAR "dwgprefix"))
  (SETQ dwgnm (GETVAR "dwgname"))
  (SETQ cur_vp (GETVAR "cvport"))
  (IF (AND (EQ (GETVAR "tilemode") 0) (/= cur_vp 1))
    (vla-put-MSpace (vla-get-Activedocument (vlax-get-Acad-Object)) :vlax-false)
;;;    (COMMAND "_.pspace")
  ) ;_ end of if
  (SETQ cur_dwgspec (STRCAT (GETVAR "dwgprefix") (GETVAR "dwgname"))
        cur_file    (DOS_FILE cur_dwgspec)
  ) ;_ end of setq
  (COMMAND ".saveas" "" "~")
  (SETQ post_dwgspec (STRCAT (GETVAR "dwgprefix") (GETVAR "dwgname"))
        post_file    (DOS_FILE post_dwgspec)
  ) ;_ end of setq
  (IF (EQUAL cur_file post_file)
    (PRINC "\nNothing Changed!")
    (PROGN
      (IF (EQ (GETVAR "dbmod") 0)
        (PROGN
          (PRINC (STRCAT "  Saved as "
                         (STRCASE (GETVAR "dwgprefix"))
                         (STRCASE (GETVAR "dwgname"))
                         ".\n"
                 ) ;_ end of strcat
          ) ;_ end of princ	  
;;;          (IF log_it NIL (LOAD "log_it" "\nFile LOG_IT.LSP not loaded! "))
;;;          (IF log_it
;;;            (PROGN
;;;              (SETQ actstr "SAVED AS")
;;;              (log_it);This func may be cause of crashes during startup
;;;            )
;;;          )
          (COMMAND ".SAVE" (STRCAT (GETVAR "dwgprefix")(GETVAR "dwgname")))
        ) ;_ end of PROGN
        (PROGN
          (PRINC (STRCAT "  NOT SAVED as"
                         (STRCASE (GETVAR "dwgprefix"))
                         (STRCASE (GETVAR "dwgname"))
                         "!\n"
                 ) ;_ end of strcat
          ) ;_ end of princ
          (ALERT (STRCAT "NOT SAVED as"
                         (STRCASE (GETVAR "dwgprefix"))
                         (STRCASE (GETVAR "dwgname"))
                         "!"
                 ) ;_ end of STRCAT
          ) ;_ end of ALERT
        ) ;_ end of PROGN
      ) ;_ end of if
      (IF c:backup NIL (LOAD "backup" "\nFile BACKUP.LSP not loaded! "))
      (c:backup)
      (IF (EQ
            (STRCASE (STRCAT dwgpx dwgnm))
            (STRCASE (STRCAT (GETVAR "dwgprefix") (GETVAR "dwgname")))
          ) ;_ end of eq
        (PROGN
          (SETQ fstr (STRCAT "  Saved.................:  "))
        ) ;_ end of progn
        (PROGN
          (SETQ fstr (STRCAT "  Saved As "
                             (GETVAR "dwgprefix")
                             (GETVAR "dwgname")
                             ":  "
                     ) ;_ end of strcat
          ) ;_ end of setq
        ) ;_ end of progn
      ) ;_ end of if
      (IF (OR (EQ (GETVAR "tilemode") 1)
              (AND (>= (STRLEN (GETVAR "dwgname")) 8)
                   (EQ (STRCASE (SUBSTR (GETVAR "dwgname") 6 1)) "X")
              ) ;_ end of and
              (WCMATCH (STRCAT (GETVAR "loginname")) "JASBILL")
              (WCMATCH (STRCAT (GETVAR "loginname")) "JFISHER")
              (WCMATCH (STRCAT (GETVAR "loginname")) "JPADGETT")
          ) ;_ end of or
        nil
        (IF (EQUAL (GETVAR "limmax") (LIST 14.0 8.5) 3)
          (c:cstmp)
          (c:lbl)
        ) ;_ end of IF
      ) ;_ end of if
      (IF dlog NIL (LOAD "dlog" "\nFile DLOG.LSP not loaded! "))
      (dlog)
    ) ;_ end of progn
  ) ;_ end of IF
  (PRINC)
) ;_ end of defun
(PRINC)
